<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-for 遍历对象</title>
  </head>
  <body>
    <div id="app">
      <ul>
        <li>{{obj.name}}</li>
        <li>{{obj.age}}</li>
        <li>{{obj.height}}</li>
      </ul>
      <br />
      <ul>
        <li v-for="item in obj">{{item}}</li>
      </ul>

      <br />
      <!-- 获取key 和value 格式：(value,key) -->
      <ul>
        <li v-for="(value,key) in obj">{{key}}-{{value}}</li>
      </ul>

      <br />
      <!-- 获取key 和value index 格式：(value,key) -->
      <ul>
        <li v-for="(value,key,index) in obj">{{index}}-{{key}}-{{value}}</li>
      </ul>
    </div>
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          obj: {
            name: "ENFB",
            age: 8,
            height: 1.66,
          },
        },
      });
    </script>
  </body>
</html>
